package com.leruan.aasimp.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.leruan.aasimp.dao.CarPartsSendDao;
import com.leruan.aasimp.entity.CarPartsSend;

public class CarPartsSendDaoImpl extends HibernateDaoSupport implements CarPartsSendDao{

	public void addPart(CarPartsSend partsSend) {
		Session session = this.getSession();
		session.save(partsSend);
	}

	public CarPartsSend getPtByID(String title) {
		Session session = this.getSession();
		Criteria cri = session.createCriteria(CarPartsSend.class);
		Criterion  c1 = Expression.eq("partsId", title);
		Criterion  c2 = Expression.eq("status", "1");
		cri.add(c1);
		cri.add(c2);
		CarPartsSend result = (CarPartsSend) cri.uniqueResult();
		return result;
	}


}
